package java_thinking.unit_21._21_13;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Desc:   13-5 可中断的锁获取操作
 * @author: cww
 * @DateTime: 2019/6/26 20:49
 */

public class InterruptibleLocking {
    private Lock lock = new ReentrantLock();

    public boolean sendOnShareLine(String message) throws InterruptedException {
        lock.lockInterruptibly();
        return cancellableSendOnSharedLine(message);
    }

    private boolean cancellableSendOnSharedLine(String message) throws InterruptedException {
        /* send something */
        return true;
    }
}
